package kr.pe.johnkim.carrotpoint.mobile.dao;

import kr.pe.johnkim.carrotpoint.mobile.domain.CarrotPointLog;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Carrot Point 로그 관련 dao 클래스 이다.
 *
 * @author : John_Kim <cale9797@gmail.com>
 * @date : 13. 2. 6.
 */
@Repository
public class CarrotPointLogDaoImpl extends SqlSessionDaoSupport implements CarrotPointLogDao {

    // SLF4J Logging
    private Logger logger = LoggerFactory.getLogger(CarrotPointLogDaoImpl.class);

    /**
     * 로그를 등록 한다.
     *
     * @param carrotPointLog
     */
    @Override
    public void registerLog(CarrotPointLog carrotPointLog) {
        logger.info("registerLog");
        this.getSqlSession().insert("CARROTPOINT_LOG.registerLog", carrotPointLog);
    }

    /**
     * 로그 목록을 가져 온다.
     *
     * @param carrotPointLog
     * @return
     */
    @Override
    public List<CarrotPointLog> getLogList(CarrotPointLog carrotPointLog) {
        logger.info("getLogList");
        return this.getSqlSession().selectList("CARROTPOINT_LOG.getLogList", carrotPointLog);
    }

    /**
     * 로그 내용을 가져 온다.
     *
     * @param carrotPointLog
     * @return
     */
    @Override
    public CarrotPointLog getLogInformation(CarrotPointLog carrotPointLog) {
        logger.info("getLogInformation");
        return (CarrotPointLog)getSqlSession().selectOne("CARROTPOINT_LOG.getLogInformation", carrotPointLog);
    }
}
